package edu.uc.ui;

import edu.uc.dto.User;
import edu.uc.service.IUserService;
import edu.uc.service.UserServiceStub;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.view.Menu;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

public class LoggedInScreen extends CeasBaseScreen {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_logged_in_screen);
		
		SharedPreferences sharedPreferences = getPreferences(MODE_PRIVATE);
		final String username = getIntent().getExtras().getString(
				IntroScreen.USER_NAME_KEY);
//		System.out.println("username: " + username);
		IUserService service = new UserServiceStub();
		try {
			User user = service.getUser(username);
			((TextView) findViewById(R.id.txtViewWelcome)).setText("Welcome " + user.getFirstName()
					+ " " + user.getLastName() + "!");
		} catch (Exception e) {
			e.printStackTrace();
		}
		
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.logged_in_screen, menu);
		return true;
	}
	
	
	public void onClick(View view) {
		Intent intent = null;
		switch (view.getId()) {
		case R.id.btnBack:
			intent = new Intent(LoggedInScreen.this,
					IntroScreen.class);
			startActivity(intent);
			break;
		case R.id.btnSaveProfile:
			Toast.makeText(LoggedInScreen.this,
					"Profile has been save successfully", 3).show();
			break;
		default:
			break;
		}
	}

}
